﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using GrayParrot.Web.Controls;
using GrayParrot.Core.Filters;
using FimetContoDeposito.DAL;
using FimetContoDeposito.BLL.Objects;

namespace FimetContoDeposito.BLL.ResultSets
{
	public class ArticoliPerFornitoreResultSet : ResultSet<FornitoreArticoloBag>
	{
        public ArticoliPerFornitoreResultSet(DTParameters param, IQueryable<FornitoreArticoloBag> result)
            : base(param, result)
        {
        }

        public override Expression<Func<FornitoreArticoloBag, bool>> ApplyGeneralFilter(string searchPattern)
        {
            var predicate = PredicateBuilder.False<FornitoreArticoloBag>();

            //if (!string.IsNullOrWhiteSpace(searchPattern))
            //{
            //    predicate = predicate.Or(im => im.Descrizione != null && im.Descrizione.ToString().Contains(searchPattern));
            //    predicate = predicate.Or(im => im.Note != null && im.Note.ToString().Contains(searchPattern));
            //}

            return predicate;
        }

        public override Expression<Func<FornitoreArticoloBag, bool>> ApplyGeneralColumnsFilter(List<string> columnSearch)
        {
            var predicate = PredicateBuilder.True<FornitoreArticoloBag>();

            //string m_id = columnSearch[ColumnIndex];
            //string m_descrizione = columnSearch[ColumnIndex];
            //string m_note = columnSearch[ColumnIndex];

            //if (!string.IsNullOrWhiteSpace(m_descrizione))
            //{
            //    predicate = predicate.And(im => im.Descrizione.Equals(m_descrizione, StringComparison.InvariantCultureIgnoreCase));
            //}

            //if (!string.IsNullOrWhiteSpace(m_note))
            //{
            //    predicate = predicate.And(im => im.Note.Equals(m_note, StringComparison.InvariantCultureIgnoreCase));
            //}

            return predicate;
        }
	}
}
